package com.tc.nacos.config;

import com.alibaba.nacos.api.annotation.NacosProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: tianchao
 * @Date: 2021/10/10 12:36
 * @Description:
 */
@SpringBootApplication
@Slf4j
public class NacosConfigApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(NacosConfigApplication.class, args);

        while (true){
            String applicationName = applicationContext.getEnvironment().getProperty("spring.application.name");
            String environment = applicationContext.getEnvironment().getProperty("common.environment");
            String name = applicationContext.getEnvironment().getProperty("common.name");
            String age = applicationContext.getEnvironment().getProperty("common.age");
            log.info("applicationName : {}",applicationName);
            log.info("environment: {}", environment );
            log.info("name:{}, age: {}", name,age);
            String es = applicationContext.getEnvironment().getProperty("common.es");
            log.info("es:::  {}", es);
            String port = applicationContext.getEnvironment().getProperty("server.port");
            log.info("port:::  {}", port);
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
